import React, { Component,Suspense} from 'react'
import {Switch,Route,Redirect} from "react-router-dom"
export class RouterView extends Component {
    render() {
        let {routes} = this.props
        return (
            <Suspense fallback={"路由加载中"}>
                <Switch>
                    {
                        routes && routes.map((item,index)=>{
                            return <Route key={index} path={item.path} render={(props)=>{
                                return item.redirect? <Redirect to={item.redirect}/>
                                :<item.component routes={item.children} {...props}></item.component>
                            }}></Route>
                        })
                    }
                </Switch>
            </Suspense>
        )
    }
}

export default RouterView
